import React, { use } from "react";
import axios from "axios";

export default function TestAxios() {
    const [data, setData] = React.useState<any>(null);
    const handleClick = () => {
        axios.get('http://iwenwiki.com:3001/api/banner')
            .then((response: { data: any; }) => {
                console.log(response.data);
                setData(response.data);
            })
    }
    return (
        <div className="test-axios">
            <h1 className="test-header"> Axios</h1>
            <button onClick={handleClick}>点我！</button>
            <div className="display-test">
                {Array.isArray(data) && data.map((item: { id: string | number; url: string; descs: string }) => (
                    <img key={item.id} src={item.url} alt={item.descs} />
                ))}
            </div>
        </div>
    );
}